package com.mobimap.nhom9.dto;


/**
 * Mapping with NodeInfo Table
 * 
 * @author xjumper
 * 
 */
public class NodeInfoDTO {
	private int id;
	LocationDTO location;
	private double heuristic = 0;
	private double d = -1; // -1 tượng trưng vô cùng lớn
	private NodeInfoDTO parentNode;

	public NodeInfoDTO() {
		this.location = new LocationDTO();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public LocationDTO getLocation() {
		return location;
	}

	public void setLocation(LocationDTO location) {
		this.location = location;
	}

	@Override
	public String toString() {
		return "NodeInfoDTO [id=" + id + ", location=" + location + "]";
	}
	
	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((location == null) ? 0 : location.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		NodeInfoDTO other = (NodeInfoDTO) obj;
		if (location == null) {
			if (other.location != null)
				return false;
		} else if (!location.equals(other.location))
			return false;
		return true;
	}

	public double getHeuristic() {
		return heuristic;
	}

	public void updateHeuristic(NodeInfoDTO target) {
		this.heuristic = LocationDTO.distance(location, target.location);
	}

	public NodeInfoDTO getParentNode() {
		return parentNode;
	}

	public void setParentNode(NodeInfoDTO parentNode) {
		this.parentNode = parentNode;
	}

	public double getD() {
		return d;
	}

	public void setD(double d) {
		this.d = d;
	}

}
